package edu.tongji.jiaowu.webapp.action.handler;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.tongji.quickCRUDQ.model.CommonBean;
import com.tongji.quickCRUDQ.util.JsonDataSet;
import com.tongji.quickCRUDQ.webapp.handler.QuickHandler;

import edu.tongji.jiaowu.service.VcodeManager;
import edu.tongji.jiaowu.service.VyearCollegeManager;

public class GradeMajorHandler extends HandlerInterceptorAdapter implements QuickHandler {
	private VcodeManager vcodeManager;
	private VyearCollegeManager vyearCollegeManager;
	
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object object, ModelAndView mv) throws Exception {
		CommonBean years=vcodeManager.findCodes("GRADE");
		String yearJson=JsonDataSet.commonbeanToJsonArray(years, "code", "name");
		CommonBean yearColleges=vyearCollegeManager.findAllVyearColleges();
		String yearCollegeJson=JsonDataSet.commonbeanToJsonArray(yearColleges, "collegeId", "collegeName", "schoolYear");
		Map model=(Map) mv.getModelMap().get("model");
		model.put("yearJson", yearJson);
		model.put("yearCollegeJson", yearCollegeJson);
		super.postHandle(request, response, object, mv);
	}
	public VcodeManager getVcodeManager() {
		return vcodeManager;
	}
	public void setVcodeManager(VcodeManager vcodeManager) {
		this.vcodeManager = vcodeManager;
	}
	public VyearCollegeManager getVyearCollegeManager() {
		return vyearCollegeManager;
	}
	public void setVyearCollegeManager(VyearCollegeManager vyearCollegeManager) {
		this.vyearCollegeManager = vyearCollegeManager;
	}

}
